home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 1 / Meeting Pearls Vol 1 (1994).iso / installed_progs / gfx / lise2.1 / lise / src / point.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-31  |  4.0 KB  |  168 lines

  1. #include <stdio.h>
  2. #ifdef AMIGA
  3. #include <gfxamiga.h>
  4. #else
  5. #include <gfx.h>
  6. #endif
  7.  
  8. int   dot_flg=TRUE,
  9.       bar_flg=FALSE,
  10.       vec_flg=FALSE,
  11.       point_style=0,
  12.       point_size=0;
  13.  
  14. help()
  15. {
  16. printf("plot a point on the grafic screen\n");
  17. printf("point x y [options]\n");
  18. printf("  -v        draws vectors \n");
  19. printf("  -c        draws circles\n");
  20. printf("  -cir n    draws circles with radius n.m\n");
  21. printf("  -crf n    draws filled circles with radius n\n");
  22. printf("  -tri n    draws triangles with baseline n (negative n gives\n");
  23. printf("                                            inverted triangles)\n");
  24. printf("  -trf n    draws filled triangles with baseline n\n");
  25. printf("  -qua n    draws quadrates with baseline n\n");
  26. printf("  -qaf n    draws filled quadrates with baseline n\n");
  27. }
  28.  
  29. disp(y,t)       /* plot a point in the window */
  30. int y,t;
  31. {
  32. int   n,m,xx,yy;
  33. float fx1,fx2,fy1,fy2,fr,phi,finc;
  34.  
  35.    xx=t; yy=y;
  36.    if(dot_flg) {
  37.       posita(xx,yy); vectoa(xx,yy);
  38.    }
  39.    if(vec_flg) {
  40.       vectoa(xx,yy);
  41.    }
  42.    switch(point_style) {
  43.    case 0:
  44.       return(0);
  45.       break;
  46.    case 1:     /* circle */
  47.       fr=point_size;
  48.       xx = t ; yy = y+fr; posita(xx,yy);
  49.       finc=1.57079/fr;
  50.       phi=finc;
  51.       fx1=0; fy1=fr;
  52.       for(n=0; n < (4*point_size); n++) {
  53.          fx2=fr*sin(phi); fy2=fr*cos(phi);
  54.          xx = t + fx2; yy = y + fy2; vectoa(xx,yy);
  55.          phi=phi+finc;
  56.       }
  57.       xx=t; yy=y; posita(xx,yy);
  58.       break;
  59.    case 2:     /* filled circle */
  60.       fr=point_size;
  61.       phi=0.0;
  62.       finc=1.57079/fr;
  63.       fx1=0; fy1=fr;
  64.       for(n=0; n <= (point_size + 1);n++) {
  65.          fx2=fr*sin(phi); fy2=fr*cos(phi);
  66.          xx=(t+fx1); yy=(y+fy1); posita(xx,yy);
  67.          xx=(t-fx1); vectoa(xx,yy);
  68.          yy=(y-fy1); posita(xx,yy);
  69.          xx=(t+fx1); vectoa(xx,yy);
  70.          fx1=fx2; fy1=fy2;
  71.          phi=phi+finc;
  72.       }
  73.       xx=t; yy=y; posita(xx,yy);
  74.       break;
  75.    case 3:     /* triangle */
  76.       xx=t+point_size; yy=y-point_size; posita(xx,yy);
  77.       xx=t-point_size; vectoa(xx,yy);
  78.       yy=y+point_size; xx=t; vectoa(xx,yy);
  79.       xx=t+point_size; yy=y-point_size; vectoa(xx,yy);
  80.       xx=t; yy=y; posita(xx,yy);
  81.       break;
  82.    case 4:     /* filled triangle */
  83.       xx=t-point_size;
  84.       for(n=0;n<(2*point_size);n++) {
  85.          yy=y+point_size; posita((int)t,yy);
  86.          yy=y-point_size; vectoa(xx,yy);
  87.          xx=xx+1;
  88.       }
  89.       xx=t; yy=y; posita(xx,yy);
  90.       break;
  91.    case 5:     /* quadrate */
  92.       xx=t+point_size; yy=y-point_size; posita(xx,yy);
  93.       xx=t-point_size; vectoa(xx,yy);
  94.       yy=y+point_size; vectoa(xx,yy);
  95.       xx=t+point_size; vectoa(xx,yy);
  96.       yy=y-point_size; vectoa(xx,yy);
  97.       xx=t; yy=y; posita(xx,yy);
  98.       break;
  99.    case 6:     /* filled quadrate */
  100.       yy=y-point_size;
  101.       for(n=0;n<(2*point_size);n++) {
  102.          xx=t+point_size; posita(xx,yy);
  103.          xx=t-point_size; vectoa(xx,yy);
  104.          yy=yy+1;
  105.       }
  106.       xx=t; yy=y; posita(xx,yy);
  107.       break;
  108.    }
  109. }
  110.  
  111. main(argc,argv)
  112. int argc;
  113. char *argv[];
  114. {
  115. int x,y,n,m,v[8];
  116. char z[80];
  117.  
  118.    x=atoi(argv[1]);
  119.    y=atoi(argv[2]);
  120.  
  121.    if(checkopt(argc,argv,"-v",z)) {
  122.       dot_flg=FALSE;
  123.       vec_flg=TRUE;
  124.    }
  125.    if(checkopt(argc,argv,"-c",z)) {
  126.       dot_flg=FALSE;
  127.       point_style=1;
  128.       point_size=4;
  129.    }
  130.    if(checkopt(argc,argv,"-cir",z)) {
  131.       dot_flg=FALSE;
  132.       point_style=1;
  133.       point_size=atoi(z);
  134.    }
  135.    if(checkopt(argc,argv,"-crf",z)) {
  136.       dot_flg=FALSE;
  137.       point_style=2;
  138.       point_size=atoi(z);
  139.    }
  140.    if(checkopt(argc,argv,"-tri",z)) {
  141.       dot_flg=FALSE;
  142.       point_style=3;
  143.       point_size=atoi(z);
  144.    }
  145.    if(checkopt(argc,argv,"-trf",z)) {
  146.       dot_flg=FALSE;
  147.       point_style=4;
  148.       point_size=atoi(z);
  149.    }
  150.    if(checkopt(argc,argv,"-qua",z)) {
  151.       dot_flg=FALSE;
  152.       point_style=5;
  153.       point_size=atoi(z);
  154.    }
  155.    if(checkopt(argc,argv,"-qaf",z)) {
  156.       dot_flg=FALSE;
  157.       point_style=6;
  158.       point_size=atoi(z);
  159.    }
  160.  
  161.    tekopen();
  162.  
  163.    disp(y,x);
  164.    gfxflush();
  165.    close(_tek4014);
  166.    return(0);
  167. }
  168.